<template>
   <div>
        <!-- 二级路由坑 -->
          <router-view v-if="$route.path=='/home/search'"></router-view>
          <div v-else>
                 <!-- 搜索框 -->
                  <van-search v-model="value" shape="round" placeholder="请输入搜索关键词" @click="linkFn" />
                  <!-- 轮播图 -->
                  <Swiper :Sarr="swiperArr"></Swiper>
                  <!-- 图标导航 -->
                  <Grid :Garr="gridArr"></Grid>
                  <!-- 新品首发 -->
                  <Newshop :Narr="newArr"></Newshop>
          </div>
         
   </div>
</template>

<script>
import { getIndexList } from "@/utils/https.js"
import Swiper from "@/components/Swiper.vue"
import Grid from "@/components/Grid.vue"
import Newshop from "@/components/Newshop.vue"
export default {
      data(){
         return {
            value:"",
            swiperArr:[],
            gridArr:[],
            newArr:[]
         }
      },
      components:{Swiper,Grid,Newshop},
      created(){
           getIndexList().then((res)=>{
            console.log(res);
                   this.swiperArr=res.data.banner
                   this.gridArr=res.data.channel
                   this.newArr=res.data.newGoodsList
           })
      },
      methods:{
         linkFn(){
         
            this.$router.push("/home/search")
            console.log(this.$route.path)
         }
      }
}
</script>

<style>

</style>